package com.xmy.cultivate.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xmy.cultivate.entity.TrainPromoteShutnum;
import com.xmy.cultivate.entity.TrainPromoteShutnumDetail;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 教师晋升关数设置详情 Mapper 接口
 * </p>
 *
 * @author hpiggy
 * @since 2025-10-18
 */
public interface TrainPromoteShutnumDetailMapper extends BaseMapper<TrainPromoteShutnumDetail> {


    @Select({"<script>",
            
            "SELECT" ,
            "t1.*," ,
            "fnGetLessonTypeName ( t1.lesson_type ) AS lesson_type_name," ,
            "getCourseTypeName ( t1.class_type_id ) AS class_type_name," ,
            "getDictName ( t1.items_id, 45 ) AS items_name," ,
            "getDictName ( t1.pass_level, 40 ) AS pass_level_name," ,
            "ev.`name` AS version_name" ,
            "FROM" ,
            "train_promote_shutnum_detail AS t1" ,
            "LEFT JOIN edu_version AS ev ON ev.id = t1.version_id" ,
            "WHERE 1= 1" ,
            "AND t1.shutnum_id = ${shutnumId}",
            
            "<when test='lessonType!=null and lessonType!=&apos;&apos; '>",
            "AND t1.lesson_type = ${lessonType} ",
            "</when>",
            "<when test='classTypeId!=null and classTypeId!=&apos;&apos; '>",
            "AND t1.class_type_id = ${classTypeId} ",
            "</when>",
            "<when test='itemsId!=null and itemsId!=&apos;&apos; '>",
            "AND t1.items_id = ${itemsId} ",
            "</when>",
            "<when test='versionId!=null and versionId!=&apos;&apos; '>",
            "AND t1.version_id = ${versionId} ",
            "</when>",
            "<when test='passLevel!=null and passLevel!=&apos;&apos; '>",
            "AND t1.pass_level = ${passLevel} ",
            "</when>",
            "<when test='num!=null and num!=&apos;&apos; '>",
            "AND t1.num = ${num} ",
            "</when>",
            "ORDER BY t1.created_at DESC",
            "</script>"
    })
    public IPage<TrainPromoteShutnumDetail> findAll(IPage<?> page,
                                                    @Param("lessonType") String lessonType,
                                                    @Param("classTypeId") String classTypeId,
                                                    @Param("itemsId") String itemsId,
                                                    @Param("versionId") String versionId,
                                                    @Param("passLevel") String passLevel,
                                                    @Param("num") String num,
                                                    @Param("shutnumId") String shutnumId);

}
